<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/7
 * Time: 15:10
 */

namespace app\api\model;


class Questionnaire extends  BaseModel
{
    protected $hidden=['admin_id','password','state'];

    public function  quests(){
        return $this->hasMany('Question','questionnaire_id',"id");
    }
    //获取Questionnarire的所有内容
    public static function getQuestionnaireByID($id){
        $questionnaire = self::with(['quests','quests.option'])
            ->find($id);
        return $questionnaire;
    }

    //获取admin下的问卷
    public  static function getQuestAdminID($adminID)
    {
        $questionnaires = self::where('admin_id','=',$adminID)
            ->select();

        return $questionnaires;
    }

}